#!/bin/sh

export CXX=g++
export CC=gcc

# 删除过期文件
rm -rf Lib
mkdir Lib

# 首先编译开源库，并将头文件拷贝到 Include 目录下，将 liblua.a 拷贝到 Lib 目录下
LUA_NAME=lua-5.3.0
rm -rf ${LUA_NAME}
tar -zxvf ${LUA_NAME}.tar.gz
cd ${LUA_NAME}
make linux

if [ ! -f src/liblua.a ]; then
    exit 1;
fi

# 拷贝文件
cp src/lua*.h* src/lauxlib.h ../Include/
cp src/liblua.a ../Lib/
cd ../

if [ ! -d Build/ ]; then
    mkdir Build
fi

cd Build
cmake ..
make
